package com.example.shiyan02.controller

import android.content.Context
import com.example.shiyan02.R
import com.example.shiyan02.model.ProgramModel
import com.example.shiyan02.view.ProgramView

class ProgramController(
    private val model: ProgramModel,
    private val view: ProgramView,
    private val context: Context
) {
    fun getProgramAdvice() {
        val programName = view.getInputProgram()

        if (programName.isEmpty()) {
            view.showError(context.getString(R.string.input_empty_error))
            return
        }

        val advice = model.getAdvice(programName, context)
        view.displayAdvice(advice)
        view.clearInput()
    }
}